<template>
  <div class="detailCompany">
    <SEADetailLeft
      :value="listValue"
      :bigListValue="bigListValue"
      :idx="idx"
      :isfullScreen="isfullScreen"
      :companyCid="companyCid"
      @refresh="refreshDetaill"
      ref="seadetaill"
    />
    <SEADetailRight :value="listValue" @refresh-detaill="refreshDetaill" />
  </div>
</template>

<script setup lang="ts">
import SEADetailLeft from '../components/EnterpriseDetaill/SEADetailLeft.vue'
import SEADetailRight from '../components/EnterpriseDetaill/SEADetailRight.vue'
import { companyGetOne, nodePageGet } from '@/api/ent/advanceSearch/index'

const isfullScreen = ref(false)
const route = useRoute()
const listValue = ref({})
const idx = ref(0)
const companyCid = ref('')
const bigListValue = ref('')

onMounted(() => {
  const { query } = route
  if (query.cid) {
    companyCid.value = query.cid
    GetDetaill(query.cid)
  }
})
const GetDetaill = async (val) => {
  const res = await companyGetOne({ cid: val })
  listValue.value = res
  GetTotalData(res, val)
}
const GetTotalData = async (res, cid) => {
  let menuList = res.menuList
  let arr = []
  menuList.forEach((item) => {
    arr = arr.concat(
      item.detailMenuVO.filter((items) => items.totalCount != 0).map((items) => items.field)
    )
  })
  let params = {
    pageNo: 1,
    pageSize: 10,
    cid: cid,
    nodes: arr
  }
  let result = await nodePageGet({ ...params })
  bigListValue.value = result
}
const refreshDetaill = (data) => {
  listValue.value.receiveUser = data.receiveUser
  listValue.value.received = data.received
  listValue.value.numberList = data.numberList
}
</script>

<style lang="scss" scoped>
.detailCompany {
  display: flex;
  height: calc(
    100vh - var(--top-tool-height) - var(--tags-view-height) - var(--app-content-padding) - var(
        --app-content-padding
      ) - var(--app-footer-height)
  );
  overflow: hidden;
}
</style>
